package controllers

import (
	"github.com/astaxie/beego"
	"analysis-ss/models"
	"analysis-ss/dao"
)

type ConfigController struct {
	beego.Controller
}

// @Title 获得孩子的课程信息
// @Description 根据中心编号获取中心对应的课程信息
// @Param	code        path	int	true	"项目编号"
// @Param	childId     	query	int	true	"孩子编号"
// @Param	start		query	int	true	"起始记录号"
// @Param	size		query	int	true	"每页记录数"
// @Success 200 {object} models.ConfigController
// @router / [post]
func (c *ConfigController) Config() {
	code := c.GetString("code")
	childId := c.GetString("childId")
	// 获得训练次数
	times := getChildCodeXLCS(childId, code)
	// 获得其他配置信息
	c.Data["json"] = append(getChildCodeConfig(childId, code), times)
	c.ServeJSON()
}

func getChildCodeXLCS(childId, code interface{}) models.ChildAbilityFeedbackConfig {
	var childXLCS models.ChildAbilityFeedbackConfig
	time, err := dao.QueryChildCodeXLCS(childId, code)
	if err != nil {
		beego.Debug(err)
	}
	childXLCS.Name = "xlcs"
	childXLCS.Value = time
	return childXLCS
}

// 获得孩子所有配置信息
func getChildCodeConfig(childId, code interface{}) []models.ChildAbilityFeedbackConfig {
	configs, err := dao.QueryChildCodeConfig(childId, code)
	if err != nil {
		beego.Debug(err)
	}
	beego.Info(configs)
	return configs
}




